#if !defined(__APP_SERIAL_H__)
#define __APP_SERIAL_H__

#include "app_device.h"
#include "app_message.h"
#include <termios.h>
typedef enum
{
    Baud9600 = B9600,
    Baud115200 = B115200
} BaudRate;

typedef enum
{
    NONE,
    ODD,
    EVEN
} Parity;

typedef enum
{
    ONE,
    TWO
} StopBits;

typedef struct SerialDeviceStruct
{
    Device super;
    BaudRate baud_rate;
    Parity parity;
    StopBits stop_bits;
} SerialDevice;

int app_serial_init(SerialDevice *serial_device, char* filename);

int app_serial_setBaudRate(SerialDevice *serial_device, BaudRate baud_rate);

int app_serial_setConnectionType(SerialDevice *serial_device, ConnectionType connection_type);

/**
 * @brief 设置串口的通信阻塞模式
 * 
 * @param mode 0 非阻塞 1 阻塞
 * @return int 0成功 -1失败
 */
int app_serial_setBlockMode(SerialDevice *serial_device, int mode);

#endif // __APP_SERIAL_H__
